/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * HaddithPanel.java
 *
 * Created on 4 mars 2012, 00:56:58
 */
package be.esi.athanfree.gui.panel;

import be.esi.athanfree.modele.AthanModele;
import java.util.Observable;
import java.util.Observer;

/**
 *
 * @author Yacine
 */
public class HaddithPanel extends javax.swing.JPanel implements Observer {

    /** Creates new form HaddithPanel */
    public HaddithPanel() {
        initComponents();
    }
    public void setModele(AthanModele modele){
        this.modele = modele;
        this.modele.addObserver(this);
         update(null, null);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        haddithTextArea = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();

        haddithTextArea.setColumns(20);
        haddithTextArea.setEditable(false);
        haddithTextArea.setRows(5);

        jLabel1.setText("Haddith Rapporté par :");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(haddithTextArea, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(335, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(85, 85, 85))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(haddithTextArea, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 14, Short.MAX_VALUE))
        );

        haddithTextArea.getAccessibleContext().setAccessibleParent(null);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea haddithTextArea;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
    private AthanModele modele;
    @Override
    public void update(Observable o, Object arg) {
        haddithTextArea.setText(modele.getHaddith().getLibellé());
        jLabel1.setText("Haddith Rapporté par : "+modele.getHaddith().getRapporté());
    }
}
